<template>
  <div class="listSever">
    <div>
      <el-form class="oldIndent_nav" ref="dataForm" style="margin:20px;">
        <div style="padding-top:10px;">
          <span style="margin-left:60px">姓名：</span>
          <el-input placeholder="请输入姓名" style="width:200px"></el-input>
          <span style="margin-left:60px">电话号码：</span>
          <el-input placeholder="请输入电话" style="width:200px"></el-input>
          <span style="margin-left:50px">下单时间:</span>
          <el-date-picker
            type="date"
            placeholder="选择下单时间"
             :picker-options="pickerOptions0"
            format="yyyy 年 MM 月 dd 日"
            value-format="yyyyMMdd"
          ></el-date-picker>
        </div>
        <el-button type="primary" round style="float:right;margin-right:200px">查询</el-button>
        <el-button class="add" type="primary" style="float:left;margin:12px;" @click="creat">添加一条</el-button>
      </el-form>
    </div>
    <el-table :data="tableData" border style="width: 100%">
      <el-table-column prop="id" align="center" label="订单号"></el-table-column>
      <el-table-column prop="time" align="center" label="下单时间"></el-table-column>
      <el-table-column prop="name" align="center" label="姓名"></el-table-column>
      <el-table-column prop="phoneNum" align="center" label="联系方式"></el-table-column>
      <el-table-column prop="sex" align="center" label="性别"></el-table-column>
      <el-table-column prop="certNum" width="220" align="center" label="身份证"></el-table-column>
      <el-table-column prop="money" align="center" label="金额"></el-table-column>
      <el-table-column prop="state" align="center" label="订单状态"></el-table-column>
      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <el-button
            size="small"
            v-show="scope.row.state==='待接单'? true: false"
            type="success"
            @click="agree(scope.row)"
          >接受订单</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 修改一条 -->
    <el-dialog :visible.sync="tableda">
      <el-form
        ref="dataForm"
        label-position="left"
        label-width="100px"
        style="width: 400px; margin-left:50px;"
      >
        <el-form-item label="姓名:">
          <el-input />
        </el-form-item>
        <el-form-item label="联系方式:">
          <el-input />
        </el-form-item>
        <el-form-item label="身份证:">
          <el-input />
        </el-form-item>
        <el-form-item label="性别:">
          <el-select v-model="value" placeholder="请选择">
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="时间:">
          <el-date-picker
            type="date"
            placeholder="选择时间"
            format="yyyy 年 MM 月 dd 日"
            :picker-options="pickerOptions0"
            value-format="yyyyMMdd"
          ></el-date-picker>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="tableda = false">取消</el-button>
        <el-button type="primary" @click="tableda = false">新增</el-button>
      </div>
    </el-dialog>
    <!-- 接受订单 -->
    <el-dialog :visible.sync="dialogFormVisible">
      <el-form
        ref="dataForm"
        label-position="left"
        label-width="70px"
        style="width: 400px; margin-left:50px;"
      >
        <el-form-item label="订单号:">
          <span>{{id}}</span>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取消</el-button>
        <el-button type="primary" @click="dialogFormVisible = false">确定接受</el-button>
      </div>
    </el-dialog>
    <!-- 分页 -->
    <el-col :span="24" class="toolbar" style="text-align: center;">
      <el-pagination
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-count="pageNum"
        :page-size="pagesize"
        style="margin-top:30px;margin-bottom:30px"
        layout="total, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </el-col>
  </div>
</template>
<script>
export default {
  data() {
    return {
      id: "",
      dialogFormVisible: false,
      currentPage: 1, // 初始页
      pagesize: 10, // 当前页面内的列表行数
      pageCount: 1,
      pageNum: 1, //页数
      total: 3,
      pickerOptions0: {
        disabledDate(time) {
          return time.getTime() < Date.now() - 8.64e7;
        }
      },
      tableda: false,
      tableData: [
        {
          id: "2122323231564",
          time: "2019-12-01 16:12",
          name: "张三",
          phoneNum: "13456559464",
          certNum: "154235456135121252",
          sex: "男",
          money: "1220",
          state: "待接单"
        },
        {
          id: "987123154",
          time: "2019-12-06 09:30",
          name: "张珊",
          phoneNum: "1894552354",
          certNum: "17615623456121541",
          sex: "女",
          money: "2000",
          state: "已接单"
        },
        {
          id: "9872123445",
          time: "2019-12-08 14:20",
          name: "刘女士",
          phoneNum: "1567855123",
          certNum: "74851235412311111",
          sex: "女",
          money: "2100",
          state: "待接单"
        }
      ],
      options: [
        {
          value: "1",
          label: "男"
        },
        {
          value: "2",
          label: "女"
        }
      ],
      value: "1"
    };
  },
  methods: {
    //当前页
    handleSizeChange: function(pagesize) {
      this.pagesize = pagesize;
    },
    // 换页：更新列表数据
    handleCurrentChange: function(currentPage) {
      this.currentPage = currentPage;
    },
    creat() {
        this.tableda = true;
    },
    agree(row) {
      this.dialogFormVisible = true;
      this.id = row.id;
    }
  },
  mounted() {}
};
</script>
<style lang="scss" scoped>
.listSever {
  margin-top: 55px;
}
</style>